/*
 * Description: 在线消息 - 群成员 控制器
 * Author: wangyifei
 * DateCreated: 2024-06-06 11:38
 */

import { type IResList, messageHttp, type IRes } from '@/utils/request';

// 查询列表
export interface MembersParam {
	avatar?: string;
	groupId?: number;
	isAdmin?: number;
	nickName?: string;
	userId?: number;
}
export interface MembersRes extends MembersParam {
	id: number;
}
export const selectMembersList = (data: MembersParam) =>
	messageHttp.post<IResList<MembersRes>>({
		url: '/chatting-group-members/list',
		data
	});

// 新增 在线消息 - 群成员
export const insertMemberItem = (data: MembersParam) =>
	messageHttp.post<IRes<MembersRes>>({
		url: '/chatting-group-members/',
		data
	});

// 新增 在线消息 - 群成员 - 多个
export const insertMembersItem = (data: MembersParam[]) =>
	messageHttp.post<IResList<MembersRes>>({
		url: '/chatting-group-members/add',
		data,
		ignoreSource: true
	});

// 退出 在线消息 - 群成员
export const quitGroupMembers = (data: MembersParam) =>
	messageHttp.post<IRes>({
		url: '/chatting-group-members/quit',
		data
	});

// 修改 在线消息 - 群成员
export const updateMembersItem = (data: MembersRes) =>
	messageHttp.put<IRes<MembersRes>>({
		url: '/chatting-group-members/',
		data
	});

// 通过id删除 在线消息 - 群成员
export const deleteMembersItem = (ids: number[]) =>
	messageHttp.delete({
		url: `/chatting-group-members/${ids.join(',')}`
	});
